VXFORM3 Aircraft Brokerage Customers Form1- Label1 Tms Rmn Label2 Last Name, First Name Tms Rmn Label3 Company Tms Rmn CustCode Tms Rmn CustName Tms Rmn CustCompany Tms Rmn Label4 Address Tms Rmn Label5 Tms Rmn Label6 State Tms Rmn CustAddress Tms Rmn CustCity Tms Rmn A CustState Tms Rmn CustStateHelp Tms Rmn Label7 Tms Rmn Label8 Res Phone Tms Rmn Label9 Bus Phone Tms Rmn Label10 Tms Rmn CustZip Tms Rmn C CustPhRes Tms Rmn D CustPhBus Tms Rmn CustFax Tms Rmn Label11 Created Tms Rmn Label12 Days on File Tms Rmn BuyRecs Bu&y Recs Tms Rmn Picture1 9 CustBuyer Buyer Tms Rmn CustSeller Seller Tms Rmn F CustCdate Tms Rmn CustDays Tms Rmn Aircraft Ai&rcraft Tms Rmn Label13 Revised Tms Rmn G CustRdate Tms Rmn CustSave &Save CustCancel &Cancel CustAdd CustDelete &Delete CustMemo &Memo CustNext &Next CustPrevious &Previous CustBrowse &Browse CustExit E&xit Label14 Status Tms Rmn CustStatus CustCode_Change Form_Click Form_Load TypeReturn BROWSE_ADDV TypeDataCleara TypeStatusH TypeSave Enabled TypeCancel TypeAdd FALSE TypeDelete7 BROWSE_EDITG CustReturnW CustDataClear CustStatus{ CustSave CustCancel CustAdd CustDelete! CustMemo TypeDataLoad vxRecNod CustDataLoad TypeCodeL TypeDesc CustCode CustName CustCompany2 CustAddressN CustCity{ CustState CustZip? CustPhRes CustPhBus CustFaxm CustBuyer Value CustSeller CustCdate CustRdatee CustDays vxField EnableCustData vxTrue vxDateFormat CreateDate DateCreated9 DateCreate DateRev will1 datesk DaysOnFile perform- DisableCustData CustCode_GotFocus BROWSE_DELETE vxDeleteRec CodeSize vxFieldSize hwndC GetFocus SendMessagea EM_LIMITTEXT- CustCode_KeyPress7 KeyAscii CustName_ChangeX CustName_KeyPressp CustCompany_Change CustCompany_KeyPress CustAddress_Change CustAddress_KeyPress CustCity_Change CustCity_KeyPress CustZip_Change CustZip_KeyPress CustPhRes_Change* CustPhRes_KeyPress@ CustPhBus_ChangeR CustPhBus_KeyPressf CustFax_Changez CustFax_KeyPress CustState_Change CustState_KeyPress CustName_GotFocus CustAddress_GotFocus CustCity_GotFocus CustState_GotFocus CustZip_GotFocus CustPhRes_GotFocus( CustPhBus_GotFocush CustFax_GotFocus4 CustSave_ClickY SeekKey EmptyStringr vxSeekD vxAppendBlank RString~ vxReplString& vxWrite vxSelectDbf AirstateDbf AircustDbf IsBuyer ThenIsBuyerX IsSeller WasBuyer WasSellero CDate RDate vxReplDateK CustStateHelp_Click VXFORM3 VXFORM1; SaveReturn BROWSE_USER StateReturn0 vxBrowsew Airstat2NtxH vxSelectNtx; Airstat1Ntx CustAdd_Click CustCancel_Click CustBrowse_Click BrowseCust) CustDelete_ClickF CustExit_Click VXFORM2 CustNext_Click vxEof vxSkips TypeNext8 TypePrev TypeBrowse vxDeletedp vxBottomT CustNext CustPrevT CustBrowsec CustPrevious_Click vxBof vxTop Form_Unload Cancel AirtypesDbf vxTableReset vxClose table CustPrevious BROWSE_MISCw CustSeller_Click CustBuyer_Click CustBuyer_KeyPress CustSeller_KeyPress Visible: Aircust1Ntx. NumRecsq vxNumRecs aircraft BuyRecsb CustKey RecNumber AirbuyerDbf vxUseDbfT Airbuy1Ntx` vxUseNtx Airbuy2Ntx OpenBuyerFile BuyerOpenb RecNum& AircraftOpen Aircraf1Ntx StatesOpen BuyRecs_Click BofExpr EofExpr$ vxTableDeclare= VX_RED Settingw scope index3 determinesz action/ vxTableField VX_FIELD going browse respectively b_code BrowseBuyers^ BuyerReturn VXFORM4C BuyerRec TypesOpen Aircraft_Click AircraftDbf Aircraf2Ntx AircraftReturn VXFORM5p BROWSE_CLOSED CursorWait CursorArrow CustMemo_Click vxMemoEdit DisableCustButtons parent disabled EnableCustButtons CustExit vxUnlock Total vxSum vxFilterc Form_Paint> vxFormFrameX BuyCodeL vxCtlStyle VX_RAISE BuyType VX_RECESS BuyTypeDesc BuyLow BuyHighS BuyStatus Picture1? Text1_ChangeI CurrHwnd SetFocusAPI TypeDelete_Click vxCtlLengthp CustCdate_Change' CustCompany_GotFocus6 buyer status removef records seller record OpenTypes OpenCust) OpenAircraft LinkBuyToSell LinkSellToBuy PackFiles TestCreate TestCopy TestDataCopy FileStruc vxWindowDereg Form3Active field Form_Load On form load analyze results of browse return Record addition request" if user pressed ENTER then file is positioned at current record and the record number isn returned in CustReturn. In this case we assume he wants to edit that record. call general proc to load controlss can't change keyA a_seller a_buyer" Edit record CustDataClear Clear Form in preparation for add or after successful deleteN dd-mmm-yyyy" dd-mmm-yyyy" CustDataLoad Load data from customer recordd ensure data entry enabled extract field valuesl a_code a_name a_company" a_address" a_city a_state" a_zip" a_phoneres a_phonebus a_fax" Return from logical field interrogation vxTrue() is -1 (TRUE) or 0 (FALSE). By using the unary negation operator we will transform any -1 values to the checkbox value 1, which means "selected" a_buyer" a_seller vxDateFormat() routine returns a date in theb format dd-mmm- y, which the Visual Basic DateValue function inderstands. We will put the creation date into a variable so we can perform some date arithmetic on it to determine the number of days on filei a_cdate" a_rdate" set customer key for other linkse EnableCustData enables all data entry controls on the form which are disabled by the CustCancel_Click Proc DisableCustData Disables data entry when the cancel buttonn is pressedd CustCode_GotFocus set up text length limit- a_code# CustCode_KeyPress Convert customer code to uppercase as it is being entered also convert enter key to tab {Tab}" CustName_KeyPress {Tab}" CustCompany_KeyPress {Tab}" CustAddress_KeyPress {Tab}" CustCity_KeyPress {Tab}" CustZip_KeyPress {Tab}" CustPhRes_KeyPress {Tab}" CustPhBus_KeyPress {Tab}" CustFax_KeyPress {Tab}" CustState_KeyPress {Tab}" CustName_GotFocus a_name# CustAddress_GotFocus a_address"# CustCity_GotFocus a_city# CustState_GotFocus a_state"# CustZip_GotFocus a_zip"# CustPhRes_GotFocus a_phoneres# CustPhBus_GotFocus a_phonebus# CustFax_GotFocus a_fax"# CustSave_Click Validate data when save button is pressed verify something in the field Field cannot be empty" verify unique key if adding Duplicate Key on Add verify that state code is in states filef on code State code not found set vxbase logical values based ond status of check box if we're updating a record, save old buyer/seller status in case we have to make adjustments to the buyer and aircraft files if the status changesn a_buyer" a_seller set up date strings in preparation for replacel dd-mmm-yyyy" dd-mmm-yyyy" a_cdate" Data passed. Put it away a_code a_name a_company" a_address" a_city a_state" a_zip" a_phoneres a_phonebus a_fax" a_buyer" a_seller a_cdate" a_rdate" we might have a new revision date a_rdate" Update status box Record " appended" Record " saved enable/display buyer/aircraft buttons set global CustKey for links to buyer and aircraft filesi save record numberr Close states file to free some handlesd also does vxTableReset- Test old buyer status and remove records from buyer file if he is no longer a buyer but once wasm in VXBMOD.BAS in cust code ordere Confirm delete of existing buyer records b_code if delete denied then reset buyer status to truer a_buyer" Test old seller status and remove record from aircraftr file if he is no longer a seller but once was in VXBMOD.BAS in cust code order- Confirm delete of existing aircraft record if delete denied then reset seller status to true a_seller reopen states filef in VXBMOD.BAS Update Button Statusa CustStateHelp_Click display a browse window on the state file. If the userr double clicks a state or presses ENTER on a highlighted record, we'll get the record number back and we can stuff the state code into CustState.textt on state name State and Provincial Abbreviations after a browse, always re-register the database with the window with a vxSelectDbf before attemptingt to access a field in the help file. statecode" CustAdd_Click clear form for addition of new record Record Addition Request" ensure data entry enabled reset the buttons CustCancel_Click Clear form data and reset button status Operation cancelled" we must disable data entry because the user could enter a new record in the blank boxes and then press the Add button. The TypeAdd_Click routine clears the form boxes again prior tol accepting input so the user's work would be lost and he would be mad.h CustBrowse_Click so we don't close files when we unload the form CustDelete_Click get user confirmation of delete Confirm Delete we must also delete any attached buyer andy aircraft recordsr set global CustKey for links to buyer and aircraft files save record number- Close states file to free some handles- also does vxTableReset- delete buyer recordst in VXBMOD.BAS in cust code orderv b_code delete aircraft record- in VXBMOD.BAS in cust code order- reopen states filee in VXBMOD.BAS now delete the requested record Deleted Delete failed" Delete cancelled CustExit_Click current form is unloaded because if needed againd the form_load proc must be invoked to reset the control datad CustNext_Click skip forward one record if skip error, only allow exit- Error on Skip Next. Try Reindex. test for end of file End of File! Skipped to record rec unlocked here CustPrevious_Click skip back one record if skip error, only allow exit Error on Skip Previous. Try Reindex. test for beginning of filer Beginning of File! Skipped to record Form_Unload close customer and state files and resete table and restart menu window if we're' NOT being unloaded by BrowseCustb CustBuyer_KeyPress {Tab}" CustSeller_KeyPress {Tab}" BuyRecs_Click Close states file to free some handles also does vxTableReset- open airtypes file and buyer file Set up browse table limited to buyer recordsn that match the CustKey. We do this by sending the vxTableDeclare proc a beginning ofr file expression and an end of file expression. b_code < ' b_code > ' The vxBrowse object now knows to limit theo records in the table to those that have b_codec values equal to CustKey. We also scope the records with the "6" following the EofExpr and set the quick key index tox "7". An explanation follows:t The key we are going to use to browse this file isi b_code + b_cat, whose elements are 6 long and 3 longl respectively. Every record we are interested in has the same b_code (i.e., they all belong to the same customer). Setting the scope index to 6 determines the action to beb taken when the HOME or END keys are depressed. The normal value is 0, which takes you to the first and last logical records in the file when HOME or END is hit. If other thant zero, then the HOME key will result in a softseek on the file to the current key for the length specified by the scope index. The END key will softseek to the current key plus 1 and then skip back one record to position the record pointer to the last record in the group. The quick index is set to 7, which is the first positiont of the aircraft type code in the key. We aren't evene going to display the b_code for the buyer records. Settingt the quick index to 7 means that the common part of the key for the group of records we are interested in (the firsti 6 which form the customer code), will be prepended to the quick keys entered at the keyboard before a seek is doned on the file. Makes sense, huh?o When scoping a file in this fashion, the only thing you MUST do is position the record pointer to the first record in the group and then pass that record numberm to the vxBrowse proc (the StartRec& parameter). b_cat" Description" b_desc b_low" b_high Because we are interested in only a subset of the possiblei records in the buyer file, we have to determine ourselves whether there are any records in the file that match the group. If not, we ask the user if he wants to add a record. vxBrowse normally does this, but the file must be empty before it asks the question and sets the return value accordingly.g global var2 set for browse start reco No buyer records. Add? Aircraft_Click there is only one aircraft sell record allowedx to a customer so this makes it a little simpler Close states file to free some handlese also does vxTableReset- open airtypes file and aircraft file- \vb\vxbtest\aircraft.dbf Error Opening aircraft.dbf. Aborting." \vb\vxbtest\aircraf1.ntx \vb\vxbtest\aircraf2.ntx No aircraft records. Add?" CustMemo_Click Edit memo. Always have an ENABLED form showing to act aso parent to the memo window. It also must have the focus. Copy the code below EXACTLY to ensure successful memoedits. save rec num to goto later make sure form has focus a_memo# reset rec bufferN unlock the record Form_Paint if delete request from browse, do it now because we must let enhanced controls paint before asking for delete confirmation CustCompany_GotFocus a_company"#